package com.ophelisis.common.core;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class LoginCheckInterceptor extends HandlerInterceptorAdapter {
	public static boolean isMenuChange = false;
	
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		HttpSession session = request.getSession(false);

		if (session == null) {
			response.sendRedirect("login.action");
			return false;
		}

		String userId = (String)session.getAttribute("userId");

		if (userId == null || userId.equals("")) {
			response.sendRedirect("login.action");
			return false;
		}
		return true;
	}
}